package org.cubikalabs.todolist.common.model
{
	import mx.collections.ArrayCollection;
	
	import org.cubikalabs.todolist.vo.Todo;

	public class TodoListManager
	{
		[Bindable]
		public var loginState:String = TodoListConstants.LOGIN_STATE_INSECURE;
		
		[Bindable]
		public var mainTodoState:String = TodoListConstants.MAIN_STATE_NORMAL;
		
		[Bindable]
		public var todoList:ArrayCollection;
		
		[Bindable]
		public var todo:Todo;
		
		public function TodoListManager()
		{
		}
		
		public function setLoginState( state:String ):void
		{
			loginState = state;
		}
	
		public function setTodoList( todoList:ArrayCollection ):void
		{
			this.todoList = todoList;
		}
		
		public function setTodo( todo:Todo ):void
		{
			this.todo = todo;
			mainTodoState = TodoListConstants.MAIN_STATE_EDITING;
		}
		
		public function createTodo():void
		{
			this.todo = new Todo();
			mainTodoState = TodoListConstants.MAIN_STATE_EDITING;
		}
		
		public function saveTodoDone():void
		{
			setTodo( null );
			mainTodoState = TodoListConstants.MAIN_STATE_NORMAL;
		}
	}
}